package com.wallet.controller;

import com.wallet.service.WalletService;
import com.wallet.util.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * 钱包Controller
 * @author zhangguangyuang
 */
@RestController
public class WalletController {

    @Resource
    private WalletService walletService;

    /**
     *  根据用户id 查询钱包中的金额
     * @param userId
     * @return
     */
    @GetMapping("/getMoneyByWallet")
    public R getMoneyByWallet(@RequestParam("userId") Integer userId){
        BigDecimal money = walletService.getMoneyInWallet(userId);
        return R.ok().put("data", money);
    }

}
